#define _CRT_SECURE_NO_WARNINGS 1
#include"Sort.h"
void TestBubbleSort()
{
	int arr[] = { 3,1,2,5,4,7,5,7,0,6,9 };
	size_t sz = sizeof(arr) / sizeof(int);
	BubbleSort(arr, sz);
	PrintArrary(arr, sz);
}

void TestHeapSort()
{
	int arr[] = { 9,1,2,5,45,0,25,7,3,23,6,0,10,4,6,3,56,76,34,6,454,343,23,767,345,
				164,864,34,54,23,6,9,65,42,21,14,365,65,443,23,46,87 };
	size_t sz = sizeof(arr) / sizeof(int);
	HeapSort(arr, sz);
	PrintArrary(arr, sz);
}
void TestInsertSort()
{
	int arr[] = { 3,1,2,5,4,7,5,7,0,6,9 };
	size_t sz = sizeof(arr) / sizeof(int);
	InsertSort(arr, sz);
	PrintArrary(arr, sz);
}
void TestShellSort()
{
	int arr[] = { 3,1,2,5,4,7,5,7,0,6,9 };
	size_t sz = sizeof(arr) / sizeof(int);
	ShellSort(arr, sz);
	PrintArrary(arr, sz);
}

void TestSelectSort()
{
	int arr[] = { 9,1,2,5,7,4,6,3 };
	size_t sz = sizeof(arr) / sizeof(int);
	SelectSort(arr, sz);
	PrintArrary(arr, sz);
}

void TestQuickSort()
{
	int arr[] = { 9,1,2,5,45,0,25,7,3,23,6,0,10,4,6,3,56,76,34,6,454,343,23,767,345,
		        164,864,34,54,23,6,9,65,42,21,14,365,65,443,23,46,87};
	size_t sz = sizeof(arr) / sizeof(int);
	QuickSort(arr, 0,sz-1);
	PrintArrary(arr, sz);
}

void TestMergeSort()
{
	int arr[] = { 9,1,2,5,45,0,25,7,3,23,6,0,10,4,6,3,56,76,34,6,454,343,23,767,345,
				164,864,34,54,23,6,9,65,42,21,14,365,65,443,23,46,87 };
	size_t sz = sizeof(arr) / sizeof(int);
	MergeSort(arr, sz);
	PrintArrary(arr, sz);
}

void TestCountSort()
{
	int arr[] = { 9,1,2,5,45,0,25,7,3,23,6,0,10,4,6,3,56,76,34,6,454,343,23,767,345,
				164,864,34,54,23,6,9,65,42,21,14,365,65,443,23,46,87 };
	size_t sz = sizeof(arr) / sizeof(int);
	CountSort(arr, sz);
	PrintArrary(arr, sz);
}

void TestDifference()
{
	int N = 100000;
	srand(time(0));
	int* a1 = (int*)malloc(sizeof(int) * N);
	int* a2 = (int*)malloc(sizeof(int) * N);
	int* a3 = (int*)malloc(sizeof(int) * N);
	int* a4 = (int*)malloc(sizeof(int) * N);
	int* a5 = (int*)malloc(sizeof(int) * N);
	int* a6 = (int*)malloc(sizeof(int) * N);
	for (int i = 0; i < N; i++)
	{
		int val = rand() + i;
		a1[i] = val;
		a2[i] = val;
		a3[i] = val;
		a4[i] = val;
		a5[i] = val;
		a6[i] = val;
	}

	int begin = clock();
	BubbleSort(a1, N);
	int end = clock();
	printf("BubbleSort: %d\n", end - begin);

	begin = clock();
	HeapSort(a2, N);
	end = clock();
	printf("HeapSort: %d\n", end - begin);
}

int main()
{
	//TestInsertSort();
	//TestHeapSort();
	//TestShellSort();
	//TestBubbleSort();
	//TestSelectSort();
	//TestQuickSort();
	//TestMergeSort();
	TestCountSort();

	//TestDifference();
	return 0;
}